function DNMFCSLT_Demos(datasetname, X,true_labels,cluster_num,layer_set, lambda1_set,lambda2_set,lambda3_set,eta1_set)
method = 'DNMFCSLT';
addpath(sprintf('%s', method));
foldname = '../results';
if ~exist(foldname, 'dir')
    mkdir(foldname);
end
foldname = sprintf('%s/%s', foldname, datasetname);
if ~exist(foldname, 'dir')
    mkdir(foldname);
end
inPara.inoptions = 'ShallowNMF';
foldname = sprintf('%s/%s', foldname, method);
if ~exist(foldname, 'dir')
    mkdir(foldname);
end
foldname = sprintf('../results/%s', datasetname);


times_clustering = 1;
NMI = zeros(times_clustering, 1);
Acc = zeros(size(NMI));
Purity = zeros(size(NMI));
tolfun_pre = 1e-4;
maxiter_pre = 100;
num_of_layers=3;
[mfea,n]=size(X);
maxiter=200;
tolfun=1e-7;
k=5;
distX=cell(1,num_of_layers);
distX1=cell(1,num_of_layers);
idx=cell(1,num_of_layers);

for i=1:size(layer_set,1)
rank_layers=layer_set(i,:);
for j = 1 : times_clustering
    filename = sprintf('initialization/%s_%s_%d_layer1=%d_layer2=%d_layer3=%d.mat', datasetname,inPara.inoptions, j,rank_layers(1),rank_layers(2),rank_layers(3));
	fprintf('initialization: %s\n', filename);
	Z = cell(1, num_of_layers);
    H = cell(1, num_of_layers);
	S = cell(1, num_of_layers);
	for i_layer = 1:num_of_layers
		if i_layer == 1
			ZZ = X;
		else
			ZZ = H{i_layer - 1};
		end
		[Z{i_layer}, H{i_layer}, ~] = ShallowNMF(ZZ, rank_layers(i_layer), maxiter_pre, tolfun_pre);
	end
	
	
	for v=1:num_of_layers
	distX{v} = EuDist2(H{v}',H{v}',0);
    [distX1{v}, idx{v}] = sort(distX{v},2);
    
    S{v} = zeros(n);
    for q = 1:n
        di = distX1{v}(q,2:k+2);
        id = idx{v}(q,2:k+2);
        S{1,v}(q,id) = (di(k+1)-di)/(k*di(k+1)-sum(di(1:k))+eps);
    end
	end
	
    save(filename, 'Z','H','S');
end
end

k_means_init=sprintf('initialization/%s_init.mat', datasetname);
load(k_means_init);
for i=1:size(layer_set,1)
	rank_layers=layer_set(i,:);
	ZCell = cell(1,times_clustering);
	HCell = cell(1,times_clustering);
	for j = 1 : times_clustering
		filename = sprintf('initialization/%s_%s_%d_layer1=%d_layer2=%d_layer3=%d.mat', datasetname,inPara.inoptions, j,rank_layers(1),rank_layers(2),rank_layers(3));
		load(filename);
		ZCell{1,j} = Z;
		HCell{1,j} = H;
		SCell{1,j} = S;
	end
	for lambda1=lambda1_set
		for lambda2=lambda2_set
			for lambda3=lambda3_set
			for eta1=eta1_set
			
				filename = sprintf('%s/%s/rank_layers=%d_%d_%d_lambda1=%f_lambda2=%f_lambda3=%f_eta1=%f.mat', ...
					foldname,method,  rank_layers(1),rank_layers(2),rank_layers(3),lambda1,lambda2,lambda3,eta1);
				fprintf('%s\n', filename);
				for j=1 :times_clustering
					fprintf('%s on %s with layer1: %d, layer2: %d, layer3: %d,  lambda1: %f, lambda2: %f, lambda3: %f, j: %d-- at %s\n', method,datasetname, rank_layers(1),rank_layers(2),rank_layers(3),lambda1,lambda2,lambda3, j, datestr(now));
					options.lambda1 = lambda1;
					options.lambda2 = lambda2;
					options.lambda3 = lambda3;
					options.eta1=eta1;
					options.maxiter=maxiter;
					options.tolfun=tolfun;
					options.cluster_num=cluster_num;
					B = full(sparse(init_labels(:, j)', 1 : n, 1, cluster_num, n, n));
					[~,Final_B,~] = DNMFCSLT(X, ZCell{1,j},HCell{1,j},SCell{1,j},B,rank_layers, options);
					results=zeros(n,1);
					for q=1:n
						for w=1:cluster_num
							if(Final_B(w,q)==1)
								results(q,1)=w;
							end
						end
					end
					[Acc(j,1),NMI(j,1),Purity(j,1)]=ClusteringMeasure(true_labels, results);
					fprintf('NMI: %f, Acc: %f, Purity: %f\n', NMI(j, 1), Acc(j, 1),Purity(j,1));
				end
			
			end
			end
		end
	end
end


end
